package com.hs.core.action;

import java.sql.Connection;

import org.apache.struts.action.Action;

import com.hs.core.db.DatabaseConnection;
public class BaseAction extends Action {
//	protected IService getBaseService(String serviceStrName) {
//		ServletContext servletContext = super.getServlet().getServletContext();
//		WebApplicationContext wac = WebApplicationContextUtils
//				.getRequiredWebApplicationContext(servletContext);
////		System.out.println("wac==="+wac);
////		try {
////			System.out.println("bean=="+wac.getBean(serviceStrName).getClass());
////			System.out.println("bean=="+(IService) wac.getBean(serviceStrName));
////		}catch (Exception e) {
////			e.printStackTrace();
////		}
//		//System.out.println("============="+wac.getBean(serviceStrName));
//		return (IService) wac.getBean(serviceStrName);
//	}
//	protected Object getBaseBean(String beanStrName) {
//		ServletContext servletContext = super.getServlet().getServletContext();
//		WebApplicationContext wac = WebApplicationContextUtils
//				.getRequiredWebApplicationContext(servletContext);
//		return wac.getBean(beanStrName);
//	}
//	 
   protected Connection getDBConn(){
	   Connection conn = null;
	   try {
		   conn =  DatabaseConnection.getConnection();
		} catch (Exception e) { 
		} finally {
			DatabaseConnection.closeConnection(conn);
		}
	return conn;
   }
}
